package com.yystudy.system.service.impl;


import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.xiaoymin.knife4j.core.util.CollectionUtils;
import com.yystudy.model.system.SysDept;
import com.yystudy.system.mapper.SysDeptMapper;
import com.yystudy.system.service.SysDeptService;
import com.yystudy.system.utils.DeptHelper;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 组织机构 服务实现类
 * </p>
 *
 * @author yystudy
 * @since 2023-10-17
 */
@Service
public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> implements SysDeptService {


    /**
     * 返回部门列表
     * @return
     */
    @Override
    public List<SysDept> findNodes() {

        //全部部门列表
        List<SysDept> SysDeptList = this.list();
        if (CollectionUtils.isEmpty(SysDeptList)) return null;

        //构建树形数据
        List<SysDept> result = DeptHelper.buildTree(SysDeptList);
        return result;
    }
}
